#pragma once
#include "ThreadPool.h"
#include "TcpServer.h"

class MyTask{
public:
    MyTask(const string &msg, int id, const TcpConnectionPtr &con);
    void process();
private:
    string _msg;
    int _id;
    TcpConnectionPtr _con;
};

class SearchEngineServer{
public:
    SearchEngineServer(size_t threadNum, size_t queSize
               , const string &ip
               , unsigned short port);
    ~SearchEngineServer();

    //让服务器启动与停止
    void start();
    void stop();

    //三个回调函数
    void onNewConnection(const TcpConnectionPtr &con);
    void onMessage(const TcpConnectionPtr &con);
    void onClose(const TcpConnectionPtr &con);

private:
    ThreadPool _pool;
    TcpServer _server;
};
